// Tags: RangeCalc
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

typedef long long ll;
const int N = 2e6 + 5;
int n, k, p, buk[N], f[N], las[N];
ll ans;

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("P1311 选择客栈.in", "r", stdin);
  freopen("P1311 选择客栈.out", "w", stdout);
#endif
#endif

  scanf("%d%d%d", &n, &k, &p);
  for (int i = 1, a, b, pre; i <= n; ++i) {
    scanf("%d%d", &a, &b);
    if (b <= p) pre = i;
    if (pre >= las[a]) f[a] = buk[a];
    ans += f[a];
    las[a] = i;
    ++buk[a];
  }
  printf("%lld", ans);
  return 0;
}